package com.alldios.deposit.api;

import chinapnr.SecureLink;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


@Component
public class HfDefines {

    @Value("${huifu.gateway}")
    private String gateway;

    @Value("${huifu.mer}")
    private String mer;

    @Value("${huifu.pri}")
    private String pri;

    @Value("${huifu.pub}")
    private String pub;

    @Value("${huifu.mercust}")
    private String mercust;

    @Value("${huifu.notice}")
    private String notice;

    @Value("${huifu.ret}")
    private String ret;

    @Value("${huifu.fee-acct}")
    private String feeAcct;

    @Value("${huifu.sub-acct}")
    private String subAcct;


    public String encrypt(String forEncryptionStr) throws Exception {
        SecureLink sl = new SecureLink();
        int result = sl.SignMsg(mer, pri, forEncryptionStr);
        if (result < 0) {

            throw new Exception();
        }
        return sl.getChkValue();
    }

    public boolean verify(String forEncryptionStr, String chkValue)
            throws Exception {
        try {
            int verifySignResult = new SecureLink().VeriSignMsg(pub, forEncryptionStr, chkValue);
            return verifySignResult == 0;
        } catch (Exception e) {

            throw new Exception();
        }
    }

    public String getGateway() {
        return gateway;
    }

    public String getMer() {
        return mer;
    }

    public String getPri() {
        return pri;
    }

    public String getPub() {
        return pub;
    }

    public String getMercust() {
        return mercust;
    }

    public String getNotice() {
        return notice;
    }

    public String getRet() {
        return ret;
    }

    public String getFeeAcct() {
        return feeAcct;
    }

    public String getSubAcct() {
        return subAcct;
    }
}
